/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package PasswrdChk02.Componentes;

import InterfacesPasswordChecker02.SumFactory;

/**
 *
 * @author geraldo
 */
public class Somatorios implements SumFactory{
    
    Simbolos simbolos = new Simbolos();
    String password;

    public Somatorios(String password) {
        this.password = password;
    }

    
    @Override
    public int somarSimbolos() {
        int total = 0;
        for (char c : password.toCharArray()) {
            if(simbolos.isSimbol(c)) 
                total++;
        }
        return total;
    }

    @Override
    public int somarMaiusculas() {
        int total = 0;
        for (char c : password.toCharArray()) {
            if (Character.isUpperCase(c)) {
                total++;
            }
        }
        return total;
    }

    @Override
    public int somarNaoLiteraisIntermediarios() {
        char[] senha = password.toCharArray();
        int total = 0;
        for (int i = 1; i < (senha.length - 1); i++) {
            if (simbolos.isSimbol(senha[i]) || Character.isDigit(senha[i])) {
                total++;
            }
        }
        return total;
    }

    @Override
    public int somarMinusculas() {
        int total = 0;
        for (char c : password.toCharArray()) {
            if (Character.isLowerCase(c)) {
                total++;
            }
        }
        return total;
    }

    @Override
    public int somarDigitos() {
        int total = 0;
        for (char c : password.toCharArray()) {
            if (Character.isDigit(c)) {
                total++;
            }
        }
        return total;
    }
    
    
    
    
}
